package com.fable.sp.core.repository;

import com.fable.sp.core.domain.LayoutItemContent;
import com.slyak.spring.jpa.GenericJpaRepository;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * .
 *
 * @author stormning on 16/8/8.
 */
public interface LayoutItemContentRepository extends GenericJpaRepository<LayoutItemContent, Long> {

    @Override
    @CacheEvict(cacheManager = "spCacheManager", value = {"lic_findByLayoutId", "lic_findOne"}, allEntries = true)
    <S extends LayoutItemContent> S save(S entity);

    @Cacheable(cacheManager = "spCacheManager", value = "lic_findByLayoutId", key = "#p0")
    List<LayoutItemContent> findByLayoutId(Long layoutId);

    @Override
    @Cacheable(cacheManager = "spCacheManager", value = "lic_findOne", key = "#p0")
    LayoutItemContent findOne(Long id);

    List<LayoutItemContent> findByLayoutItemId(Long id);

    LayoutItemContent findByLayoutIdAndContentId(long layoutId, long contentId);
}
